package com.by.toolkit.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum UserQueryConditionTypeEnum {

    USER_ID(1, "用户id"),
    PHONE(2, "手机号"),
    NICK_NAME(3, "昵称"),
    ;

    private Integer code;
    private String desc;


    public static final Map<Integer, UserQueryConditionTypeEnum> MAP = Arrays.stream(UserQueryConditionTypeEnum.values())
            .collect(Collectors.toMap(UserQueryConditionTypeEnum::getCode, Function.identity()));

    public static UserQueryConditionTypeEnum resolve(Integer code) {
        return MAP.get(code);
    }

}
